package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.dto.SetmealPageQueryDTO;
import com.sky.entity.Setmeal;
import com.sky.vo.SetmealVO;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

@Mapper
public interface SetmealMapper {

    /**
     * 根据分类id查询套餐的数量
     * @param id
     * @return
     */
    @Select("select count(id) from setmeal where category_id = #{categoryId}")
    Integer countByCategoryId(Long id);

    /**
     * 保存dish的基本信息
     * @param setmeal
     */
    void save(Setmeal setmeal);

    /**
     * 分页查询
     *
     * @param setmealPageQueryDTO
     * @return
     */
    Page<SetmealVO> page(SetmealPageQueryDTO setmealPageQueryDTO);

    /**
     *
     * @param id
     * @return
     */
    @Select("select * from setmeal where id=#{id}")
    Setmeal findById(Long id);
    /**
     * 停售起售状态
     * @param status
     * @param id
     */
//    @autoFill(value = OperationType.UPDATE)
    @Update("update setmeal set status=#{status} where id=#{id}")
    void updateStatus(Long status, Integer id);

    /**
     *删除数据
     * @param id
     */
    @Delete("delete from setmeal where id=#{id}")
    void delete(Long id);

    /**
     * 更新数据
     * @param setmeal
     */

    void update(Setmeal setmeal);
}
